package com.util;

import com.exception.CustomerException;
import com.fasterxml.jackson.databind.ObjectMapper;



public class JsonUtils {


    public static ObjectMapper objectMapper=new ObjectMapper();


    /**
     * 转换json
     * @param object
     * @return
     */
    public static String writerValueAsString(Object object){

        try {
            String json = objectMapper.writeValueAsString(object);
            return json;
        }catch (Exception e){
            e.printStackTrace();
            throw new CustomerException("json转换失败!");
        }
    }

}
